home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 23
/
Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso
/
Aminet
/
text
/
edit
/
Smartindent.lha
/
Smartindent
/
Source
/
test_correct.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-12-14
|
7KB
|
302 lines
/* Don't think about this code...
** It is nonsense, but shows several posibilities than can occure in real
** live. When you can think of anything else to be tested, please mail an
** according piece of code to me.
**
** The file test_correct.c is indented as smartindent *should* indent it.
** The file test_input.c is completely wrong indented and the input file
** for 'smake test' (see below).
**
** However not everything works right now as it should.
** Do 'smake test' in order to test correct indention process.
** For this you will have to have a 'diff' utility in your path.
**
** Some lines contain a comment / * !!! BUG !!! * /
** (no spaces between * and / and before and after BUG -
** it cannot be printed here verbosely, otherwise the semantic parser
** could have strange effects on this comment line...)
** Guess on which lines...
**
** Note that not everything can be tested that way.
** For example, when a line is indented more or less than it should be
** and *only* the next lines are to be indented, it will take the (wrong)
** indention of the line above and use it instead of the calculated value.
** I found that better for daily use than obductrinating calculated
** indentions.
**
** e.g. the code will be block indented
** { {
** blafoo; blafoo;
** asdf; asdf;
** } }
** but when you only indent the line 'asdf;', you will get
** {
** blaffo;
** asdf;
** }
**
** Matthias Hopf <mshopf@informatik.uni-erlangen.de>
*/
/* first column comment */
/* indented comment */
/* Mulitline w/o starter, begining first line.
this is second line
Line after empty line
*/
/* Mulitline w/o starter, begining first line.
this time end of comment in last text line. */
/*
Mulitline w/o starter, begining first empty line.
this is second line
*/
/*
* Mulitline w '*' starter, begining first empty line.
* this is second line
*/
/* Mulitline w '*' starter, begining first line.
* this time end of comment in last text line. */
/*
** Mulitline w '**' starter, begining first empty line.
** this is second line
*/
/*
* Mulitline mixed mode.
This may have strange results.
But who cares, anyone using this is mad anyway.
** Don't you think so?
*/
/* */ /* double comment */ /* !!!BUG!!! */
/* */ /* empty comment */ /* !!!BUG!!! */
// asdf /* spaced first word in // comment */ /* !!!BUG!!! */
#if asdf
# error
#endif
#define macro qwer \
blafoo \
ssss
asdf;
#define macro(x) qwer \
blafoo \
sss
asdf;
# define macro(x) \
qwer \
asdf
# define \
sss
asdf;
struct test { /* in-line comment */
int i; // C++ comment
char v [
10];
}
asdf;
extern int mm = /* This comment disturbs the next line */
d; /* !!!BUG!!! */
extern int i,
j = /* !!!BUG!!!*/ /* This line should be indented under 'i' */
test * 5 +
77 - asdf
+ nix,
k = (
asdf
) + (
qwer);
void
function (x,y,z)
{ blafoo; /* !!!BUG!!! */ /* This code should be indented at block level. */
struct TableElem
{
TableElem *next;
int asdf;
void (*func) (int, char *, unsigned
long);
int bla,
foo; /* !!!BUG!!! */ /* Should be indented under 'bla'. Currently Cont_Level is used. */
}
i =
{
0,
1,
adsf ? qwer :
asdf,
(j == qwer),
'x',
"This is a String"
" even more string"
}
; /* !!!BUG!!! *//* Oops.. Strange side effect... :-( */
struct TableElem i = {
0,
1
} ;
blafoo (x);
cout >> "Hello "
>> "World!";
Temp::Temp(adf);
i = (asdf ?
qewwew :
qeww );
i = asdf ?
qewwew :
qeww;
i = asdf ?
qewwew
: qeww;
i = j =
k;
i = (j =
k);
i +=
k;
i &&=
k;
if (i ==
j)
bla;
if (i <=
j)
bla;
if ( (i =
j) )
bla;
if ( (i +=
j) )
bla;
if ( (i &&=
j) )
bla;
if ( (i =
j ==
k) )
bla;
if ( (i = j) &&
k == l ||
m !=
o)
bla;
asdf:
bla;
TableElem():next(0),elem(0){}
foo;
switch (c) {
bla;
case 0:
foo;
default:
}
for (asdf;
qwer;
ttt)
i++;
bla;
while (1)
i++;
bla;
while (1) i++;
bla;
if (x) asdf;
else qwer;
bla;
if (x) if (y) asdf;
else qwer;
bla;
if (x)
if (y)
a;
else
b;
else
c;
if (x)
if (y)
{
if (z)
a;
}
else
{
d;
}
else
f;
if (a)
switch (b) {
}
asdf; /* !!!BUG!!! */ /* thought to be still inside block */
bla;
if (a)
yxcv;
else
for (;;)
asdf;
qwer; /* !!!BUG!!! */ /* thought to be still inside block */
bla;
if (a)
try { /* don't know whether this will ever be correct, because it is mad! */
asdf();
}
catch (x) { /* err, this is correctly indeted by accident :] */
bla; /* !!!BUG!!! */ /* should be gone by correcting the above ones */
} /* !!!BUG!!! */ /* should be gone by correcting the above ones */
catch (y) /* err, this is again correctly indented by accident :] */
{ /* !!!BUG!!! */ /* should ... */
foo; /* dto. */
} /* dto. */
qwer; /* !!!BUG!!! */ /* correlated to the above ones */
blubs;
}
/* C++ errors - Henning Tietgens <hawk@informatik.uni-bremen.de> */
class test_child : public test
{
public:
void testing();
};
void test::testing()
{
cout << "Test"
<< endl;
}
/* Nested comments error - Marty King <mking@atl.com> */
/* Note: default is now unnested comments (compile-time option, see semantics_c.c) */
/* first level comment
/* second level comment
void main() {}
*/
void test() {} /* this would be thought to be a comment when using nested comments */
*/
void main() {} /* outside comments */